var t = require("../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Page({
    data: {
        searchVal: "",
        levelData: [],
        activeData: [],
        active: "",
        id: "",
        show: !1
    },
    onLoad: function(t) {
        this.setData({
            id: t.id
        }), this.getLevelData();
    },
    getLevelData: function() {
        var i = this, e = this.data.id ? "plugin.new-blind-box.frontend.activity.activity-level" : "plugin.new-blind-box.frontend.activity.level", s = this.data.id ? {
            id: this.data.id
        } : "";
        a._postNetWork({
            url: a.getNetAddresss(e),
            data: t({}, s),
            success: function(t) {
                var a = t.data;
                a.result ? (i.setData({
                    active: a.data.list[0].id,
                    levelData: a.data.list,
                    show: !0
                }), i.searchActivityGoods()) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    searchActivityGoods: function() {
        var i = this, e = this.data.id ? "plugin.new-blind-box.frontend.activity.search-activity-goods" : "plugin.new-blind-box.frontend.activity.search-level-goods", s = this.data.id ? {
            id: this.data.id,
            level_id: this.data.active,
            search: {
                goods_keyword: this.data.searchVal
            }
        } : {
            level_id: this.data.active,
            search: {
                goods_keyword: this.data.searchVal
            }
        };
        a._postNetWork({
            url: a.getNetAddresss(e),
            data: t({}, s),
            success: function(t) {
                var a = t.data;
                a.result ? i.setData({
                    activeData: a.data.goods ? a.data.goods : a.data.list
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onChangeTab: function(t) {
        this.setData({
            active: t.detail.name
        }), this.searchActivityGoods();
    },
    onChangeSearch: function(t) {
        this.setData({
            searchVal: t.detail
        });
    }
});